#!/bin/bash
########################################################################
####  Script Name: rbxi-values
####  Version: 2.7.2
####  Date: 4 September 2009
########################################################################
#### Note: you can create any number of these rbxi-values files, and load
#### alternate values files by using the -V option. See rbxi -h for details.
#### File must be in rbxi-data, and the name must be rbxi-values-<anything>
#### The value for -V must be <anything>, and the file will be tested for.
########################################################################

########################################################################
#### RSYNC/RDIFF-BACKUP DATA, REQUIRED APPLICATION PATHS ###############
########################################################################

# set to either rdiff-backup or rsync. 
# Option: [rd/rs] - rd is rdiff-backup and rs is rsync.
BACKUP_APP='rsync'

# change these to the true system paths if you are going to run this as a cron job
# like so: RDIFF_PATH='/usr/bin/rdiff-backup'
# Use'which rdiff-backup' OR 'which rsync' (no quotes) to find the true path.
RDIFF_PATH='rdiff-backup'
RSYNC_PATH='rsync'

# If you know your preferred options, just put them in here.
# ie: RSYNC_EXTRA_OPTIONS=' --rsh=ssh'
# RSYNC_EXTRA_OPTIONS=' --dry-run -v ' # for verbose, testing only, no actual backup
# or deletion of previous backups or directories
# only set if it's a remote machine, otherwise make null: RSYNC_EXTRA_OPTIONS=''
RSYNC_EXTRA_OPTIONS=' --dry-run -v --stats '
RDIFF_EXTRA_OPTIONS=' --terminal-verbosity 5 '

# see man rdiff-backup for proper syntax for time. This is set to remove older
# than 60 days incremental backupsThe time  interval  is  an integer followed
# by the character s, m, h, D, W, M, or Y, indicating seconds, minutes, hours, days,
# weeks, months, or years respectively, or a number of these concatenated.
# For example, 32m  means  32  minutes; 3W2D10h7s  means 3 weeks, 2 days, 10 hours, and 7 seconds.
RDIFF_REMOVE_TIME='60D'

####################################################################################
#### BACKUP (DESTINATION) MOUNT POINT DIRECTORY PATHS AND INFORMATION ##############
####################################################################################
#    << CHANGE TO YOUR BACKUP MOUNT POINT LOCATION AND DIRECTORY PATHS >>
#
# This is either a mount point, or a partition on the running OS HD
#
# REMEMBER, DO NOT BACKUP BACKUP_MOUNT_POINT ITSELF, MAKE SURE TO BLOCK IT
# IN THE EXCLUDE FILE LIST, OTHERWISE YOU WILL BACKUP YOUR BACKUP!!
#
# DO NOT END the destination directory names below with a '/'
# START them with a / unless it's a remote mount:
# remote machine drives that are not mounted on your local system must be in this form:
# BACKUP_MOUNT_POINT='username@machine:/path/to/backup/destination'
#
# Option: -B <1-10>
#
# primary rdiff-backup directory (sample)
BACKUP_MOUNT_POINT='/media/esata'
BACKUP_MOUNT_POINT_1=''
BACKUP_MOUNT_POINT_2=''
BACKUP_MOUNT_POINT_3=''
BACKUP_MOUNT_POINT_4=''
BACKUP_MOUNT_POINT_5=''
BACKUP_MOUNT_POINT_6=''
BACKUP_MOUNT_POINT_7=''
BACKUP_MOUNT_POINT_8=''
BACKUP_MOUNT_POINT_9=''
BACKUP_MOUNT_POINT_10=''

# set rsync backup directory separately
# primary rdiff-backup directory (sample):
BACKUP_MOUNT_POINT_RS='/media/esata'
BACKUP_MOUNT_POINT_1_RS=''
BACKUP_MOUNT_POINT_2_RS=''
BACKUP_MOUNT_POINT_3_RS=''
BACKUP_MOUNT_POINT_4_RS=''
BACKUP_MOUNT_POINT_5_RS=''
BACKUP_MOUNT_POINT_6_RS=''
BACKUP_MOUNT_POINT_7_RS=''
BACKUP_MOUNT_POINT_8_RS=''
BACKUP_MOUNT_POINT_9_RS=''
BACKUP_MOUNT_POINT_10_RS=''

# Primary backup job directories, these will be located inside of the BACKUP_MOUNT_POINT
# I strongly recommend you use these, because that can help avoid accidently writing the
# backup to a directory that did not get mounted, for example: /media/backup prior to
# mounting the actual drive  to /media/backup. This is an easy mistake to make.
# DO NOT END the destination directory names below with a '/'
# START them with a /
#
# Option -D <1-10>
#
# rdiff-backup sub directory name (sample):):
BACKUP_MOUNT_POINT_DIRECTORY='/backup'
BACKUP_MOUNT_POINT_DIRECTORY_1=''
BACKUP_MOUNT_POINT_DIRECTORY_2=''
BACKUP_MOUNT_POINT_DIRECTORY_3=''
BACKUP_MOUNT_POINT_DIRECTORY_4=''
BACKUP_MOUNT_POINT_DIRECTORY_5=''
BACKUP_MOUNT_POINT_DIRECTORY_6=''
BACKUP_MOUNT_POINT_DIRECTORY_7=''
BACKUP_MOUNT_POINT_DIRECTORY_8=''
BACKUP_MOUNT_POINT_DIRECTORY_9=''
BACKUP_MOUNT_POINT_DIRECTORY_10=''

# rsync sub directory name (sample):
BACKUP_MOUNT_POINT_DIRECTORY_RS='/backup-rs'
BACKUP_MOUNT_POINT_DIRECTORY_1_RS=''
BACKUP_MOUNT_POINT_DIRECTORY_2_RS=''
BACKUP_MOUNT_POINT_DIRECTORY_3_RS=''
BACKUP_MOUNT_POINT_DIRECTORY_4_RS=''
BACKUP_MOUNT_POINT_DIRECTORY_5_RS=''
BACKUP_MOUNT_POINT_DIRECTORY_6_RS=''
BACKUP_MOUNT_POINT_DIRECTORY_7_RS=''
BACKUP_MOUNT_POINT_DIRECTORY_8_RS=''
BACKUP_MOUNT_POINT_DIRECTORY_9_RS=''
BACKUP_MOUNT_POINT_DIRECTORY_10_RS=''

####--------------------------------------------------------------------
#### BACKUP DESTINATION SUB DIRECTORIES --------------------------------
####--------------------------------------------------------------------
# << CHANGE TO MEET YOUR NEEDS >>

# specific main backup subdirectory names, eg: /media/usbdisk/bu-2/home and so on
# NOTE: if either of these is left blank, the script will not back up that item unless
# you override it with a -C (clone) option, which also sets these to blank anyway, except home.
# You do not need to create the following subdirectories, rsync/rdiff-backup will create them
# automatically using the names you give here
#
# Option: To Skip: -S <d|h|hr|r|1-10> To Add: -A <d|h|hr|r|1-10> (repeat as many times as needed)
#
HOME_DIR='home'
ROOT_DIR='root-hda1'

# these are optional backup subdirectories, if these are used the script will backup these
# as well as / and /home autumatically.
# Blank '' means the script does not try to back that item up
# This is the backup sub directory name, not the actual data file path
DATA_1_DIR=''
DATA_2_DIR=''
DATA_3_DIR=''
DATA_4_DIR=''
DATA_5_DIR=''
DATA_6_DIR=''
DATA_7_DIR=''
DATA_8_DIR=''
DATA_9_DIR=''
DATA_10_DIR=''

########################################################################
#### SCRIPT BACKUP OUTPUT DESCRIPTIONS #################################
########################################################################

# << CHANGE TO YOUR PREFERRED OUTPUT TEXT FOR EXTRA DATA 1/2 BACKUPS >>
#
# these should match with the XXX_DIR/XXX_PATH above and below, and just define
# what output the script prints out to you as it's backing up each direcy.
DATA_1_DESC='' # for example: DATA_1_DESC='web'
DATA_2_DESC='' # for example: DATA_2_DESC='email'
DATA_3_DESC=''
DATA_4_DESC=''
DATA_5_DESC=''
DATA_6_DESC=''
DATA_7_DESC=''
DATA_8_DESC=''
DATA_9_DESC=''
DATA_10_DESC=''

# this is only for print output, it's not used in the actual backup
# << CHANGE TO YOUR ROOT PARTITION FULL PATH >>
ROOT_DESC='/dev/hda1'

########################################################################
#### SYSTEM BACKUP SOURCE PATH INFORMATION #############################
########################################################################
# << CHANGE TO YOUR SYSTEM PATHS FOR HOME / + EXTRA BACKUP PATHS IF NEEDED >>

# These are the actual directory paths you want to backup, the SOURCE directories.
# Should not change these unless you are backing up an install from outside of it
# Note: if you leave off the ending /, rsync will create a directory of the last name in
# the path, which you probably don't want.
HOME_PATH='/home/'
ROOT_PATH='/'

# these are optional extra backups, set to absolute path if you are using them
# Correspond to BU_DATA_x, for example: /home/username/data
# This is the actual file path in your system
#
# If the above XXX_DIR items are blank, rbxi will not back these directories up
# unless you use a specific C override, or use -A <number>
# In all cases, however, these paths must be real and must exist on your system
# if is is a local path.
# remote machines must be in this form: username@machine:/path/to/backup/source
DATA_1_PATH=''
DATA_2_PATH=''
DATA_3_PATH=''
DATA_4_PATH=''
DATA_5_PATH=''
DATA_6_PATH=''
DATA_7_PATH=''
DATA_8_PATH=''
DATA_9_PATH=''
DATA_10_PATH=''

########################################################################
#### PARTITION MOUNT/UMOUNT ############################################
########################################################################
# << CHANGE TO FIT YOUR NEEDS >>
#
# Note that MOUNT/UNMOUNT 1-10 are triggered by the -M option
#
# if you are not going to be mounting/unmounting your backup partition / disk,
# then set value to blank:
# MOUNT_BU_DISK=''
# UNMOUNT_BU_DISK=''
# Note: you can use anything here, </dev/sdd1>; -L <disk label>; -U <disk uuid>
# replace <....> with your label,uuid, or /dev/...
# Syntax for label: mount -L <disklabel> $BACKUP_MOUNT_POINT
# Syntax for uuid: mount -U <uuid> $BACKUP_MOUNT_POINT
# Syntax for standard: mount </dev/sdd2> $BACKUP_MOUNT_POINT
#
# If you are using NFS mounted directories, the host nfs server must have these permissions set
# in /etc/exports: rw,async,,no_root_squash or write permissions will fail in rsync
#
# IMPORTANT: DO NOT USE " " quotes, because the $BACKUP_MOUNT_POINT will be evaluated later
# after the final BACKUP_MOUNT_POINT has been set in the script. Use '' to handle this!
# note: the proper rdiff/rsync directory will be assigned later by script
# For cron jobs, put the full system path to mount/umount here in the command.
# use 'which mount' OR 'which umount' (no quotes) to find the true path.
#
# EXCEPTION: if you want to use a custom DIRECTORY from above, do it like this:
# MOUNT_BU_DISK="mount -L backup-disk-1 $BACKUP_MOUNT_POINT_3"
# UNMOUNT_BU_DISK="umount $BACKUP_MOUNT_POINT_3"
# this will then use the directory you list. This requires double quotes, "", not single, ''
# of course you can also just hard code in the entire thing if you want, but it's easier to
# avoid errors if you just type it in time I find.
#
# If you are just needing to change the BACKUP_MOUNT_POINT, just use -B <bu directory number>
# instead and rbxi will change that automatically for you, but if you need to put actually
# different mount/umount information, then use an alternate MOUNT/UNMOUNT number
#
# Option: -M <1-10>
#
## DEFAULT MOUNT
MOUNT_BU_DISK='mount -L backup-disk-1 $BACKUP_MOUNT_POINT'
UNMOUNT_BU_DISK='umount $BACKUP_MOUNT_POINT'
## OPTIONAL MOUNT SET
MOUNT_BU_DISK_1=''
UNMOUNT_BU_DISK_1=''
MOUNT_BU_DISK_2=''
UNMOUNT_BU_DISK_2=''
MOUNT_BU_DISK_3=''
UNMOUNT_BU_DISK_3=''
MOUNT_BU_DISK_4=''
UNMOUNT_BU_DISK_4=''
MOUNT_BU_DISK_5=''
UNMOUNT_BU_DISK_5=''
MOUNT_BU_DISK_6=''
UNMOUNT_BU_DISK_6=''
MOUNT_BU_DISK_7=''
UNMOUNT_BU_DISK_7=''
MOUNT_BU_DISK_8=''
UNMOUNT_BU_DISK_8=''
MOUNT_BU_DISK_9=''
UNMOUNT_BU_DISK_9=''
MOUNT_BU_DISK_10=''
UNMOUNT_BU_DISK_10=''

########################################################################
#### JOB PRESETS #######################################################
########################################################################
# set with whatever arguments you want to start script with, script will restart with those options
# automatically, then run whatever job you set.
# Jobs consist of <job name> plus ':' plus <sets of rbxi options>
# sample: BACKUP_JOB_1='system-b-bu: -M 3 -S rh ' - this would use mount/umount 3, and skip home/root backup
# sample: BACKUP_JOB_2='system-c-bu: -M 2 -S rh -A 8' - this would use mount/umount 2, skip home/root backup
# and Add the normally turned off DATA_8
#
# Option: -J <1-10>
#
# syntax: 'job-display-name: <job options>'
BACKUP_JOB_1=':'
BACKUP_JOB_2=':'
BACKUP_JOB_3=':'
BACKUP_JOB_4=':'
BACKUP_JOB_5=':'
BACKUP_JOB_6=':'
BACKUP_JOB_7=':'
BACKUP_JOB_8=':'
BACKUP_JOB_9=':'
BACKUP_JOB_10=':'

########################################################################
#### CLEAN / DELETE / BACKUP / SKIP ####################################
########################################################################
# these are for options, used in case of cron or option run backups/deletes
# if you want to hard set any option just set the variable to true.
# trigger rdiff/rsync cleeanup, either older than x, or remove deleted files
# Option: -c :clean old backup files, then do backup
B_CLEAN_OLDER='false'
# Option: -d :delete old backup, then do backup
B_DELETE_BACKUP='false'
# Option: -b :automatic backup
B_DO_BACKUP='false'

# skip home/root/data can be overridden by -A <r|h|number> when you are creating
# a separate job (-J <number>).
B_SKIP_DATA_FULL='false' # -C [..] or -S d - skips all data partition backups
B_SKIP_DATA_1='false' # -S 1
B_SKIP_DATA_2='false' # -S 2
B_SKIP_DATA_3='false' # -S 3
B_SKIP_DATA_4='false' # -S 4
B_SKIP_DATA_5='false' # -S 5
B_SKIP_DATA_6='false' # -S 6
B_SKIP_DATA_7='false' # -S 7
B_SKIP_DATA_8='false' # -S 8
B_SKIP_DATA_9='false' # -S 9
B_SKIP_DATA_10='false' # -S 10
B_SKIP_HOME='false' # -S h
B_SKIP_ROOT='false' # -S r

########################################################################
#### ADVANCED USER SET FUNCTIONS/ACTIONS ###############################
########################################################################

# The following allow for user customization of rbxi actions using a simple
# api that will run either pre-defined functions or actions when desired.

####--------------------------------------------------------------------
#### PRE/POST MOUNT/UMOUNT FUNCTIONS -----------------------------------
####--------------------------------------------------------------------

# If the first, non numbered variable contains the function, rbxi will always
# execute that every time it runs, unless overridden by -P <...>
#
# Note that each function must return 0 for success, and > 0 for failure. rbxi error 
# handling requires this to properly exit and halt on failure. If no error handling
# is required, then simply return 0 at the end of the function.
# Functions must be written in Bash.
# 
# Important! If you use variables in your functions, make sure to either make them local, 
# like: local variablename='', or by starting the variables with a prefix: like: ppmm_
# that is unique. Otherwise you might accidently overwrite a script variable.
# 
# Option: -P <1-5>:<1-5>:<1-5> where any number can be skipped: like so: -P 2::2
# that would trigger PRE_MOUNT_FUNCTION_2 and POST_UMOUNT_FUNCTION_2 but not
# POST_MOUNT_FUNCTION, for example. See readme-rbxi.htm for some samples.
#
# launches function: pre_mount_tasks()
PRE_MOUNT_FUNCTION=''
PRE_MOUNT_FUNCTION_1=''
PRE_MOUNT_FUNCTION_2=''
PRE_MOUNT_FUNCTION_3=''
PRE_MOUNT_FUNCTION_4=''
PRE_MOUNT_FUNCTION_5=''
PRE_MOUNT_FUNCTION_6=''
PRE_MOUNT_FUNCTION_7=''
PRE_MOUNT_FUNCTION_8=''
PRE_MOUNT_FUNCTION_9=''
PRE_MOUNT_FUNCTION_10=''

# launches function post_mount_tasks()
POST_MOUNT_FUNCTION=''
POST_MOUNT_FUNCTION_1=''
POST_MOUNT_FUNCTION_2=''
POST_MOUNT_FUNCTION_3=''
POST_MOUNT_FUNCTION_4=''
POST_MOUNT_FUNCTION_5=''
POST_MOUNT_FUNCTION_6=''
POST_MOUNT_FUNCTION_7=''
POST_MOUNT_FUNCTION_8=''
POST_MOUNT_FUNCTION_9=''
POST_MOUNT_FUNCTION_10=''

# launches function post_umount_tasks()
POST_UMOUNT_FUNCTION=''
POST_UMOUNT_FUNCTION_1=''
POST_UMOUNT_FUNCTION_2=''
POST_UMOUNT_FUNCTION_3=''
POST_UMOUNT_FUNCTION_4=''
POST_UMOUNT_FUNCTION_5=''
POST_UMOUNT_FUNCTION_6=''
POST_UMOUNT_FUNCTION_7=''
POST_UMOUNT_FUNCTION_8=''
POST_UMOUNT_FUNCTION_9=''
POST_UMOUNT_FUNCTION_10=''

####--------------------------------------------------------------------
#### EMAILER ACTIONS ---------------------------------------------------
####--------------------------------------------------------------------

# these work much the same as above, only they do NOT use a function, just
# a scripted action, which will for most people be emailing the sys admin,
# but you can put any actions you want in here as well that you want done
# that rbxi doesn't do already. Errors from the action cannot be handled 
# unless you make your action scripting itself process it.
#
# You can get rbxi error handling by using the following in your action code, 
# triggered by whatever error condition you want: error_handler 31 "your error data"
# Error 31 is a generic User Action error code for this feature.

# Actions must be written in Bash, or any other language you can call directly
# on the system that is running the backup.
#
# These actions will be triggered in a function that will have access to the
# following data, called with "$data" (" quotes are NOT optional). $data is time
# stamped always for start/finish/error.
#
# All code must be contained in a block using single quotes for the eval to work with  '
# the "$data" variable. 
# 
# EMAIL_START_ACTION: $data is the startup options rbxi is running with, and the start time
# EMAIL_FINISH_ACTION: $data is the startup options, plus the finish time.
# EMAIL_ERROR_ACTION: $data is the error message from the error handler, including error
# numbers and error time.
# 
# Sample (can be multiline action also).
# EMAIL_ERROR_ACTION_1='nail -r "myaddress@something.com" -s "Backup Error on Raven" -S smtp=some.smtp.server info@company.com <<< "$data"'
#
# Option: -E <1-10>:<1-10>:<1-10> where any number can be skipped: like so: -E 2::2
# that would trigger EMAIL_START_ACTION_2 and EMAIL_ERROR_ACTION_2 but not
# EMAIL_FINISH_ACTION, for example. See readme-rbxi.htm for some samples.
#
# Alerts to start of backup operation
EMAIL_START_ACTION=''
EMAIL_START_ACTION_1=''
EMAIL_START_ACTION_2=''
EMAIL_START_ACTION_3=''
EMAIL_START_ACTION_4=''
EMAIL_START_ACTION_5=''
EMAIL_START_ACTION_6=''
EMAIL_START_ACTION_7=''
EMAIL_START_ACTION_8=''
EMAIL_START_ACTION_9=''
EMAIL_START_ACTION_10=''

# Alerts to finish of backup operation
EMAIL_FINISH_ACTION=''
EMAIL_FINISH_ACTION_1=''
EMAIL_FINISH_ACTION_2=''
EMAIL_FINISH_ACTION_3=''
EMAIL_FINISH_ACTION_4=''
EMAIL_FINISH_ACTION_5=''
EMAIL_FINISH_ACTION_6=''
EMAIL_FINISH_ACTION_7=''
EMAIL_FINISH_ACTION_8=''
EMAIL_FINISH_ACTION_9=''
EMAIL_FINISH_ACTION_10=''

# Alerts to backup error, should include error data.
EMAIL_ERROR_ACTION=''
EMAIL_ERROR_ACTION_1=''
EMAIL_ERROR_ACTION_2=''
EMAIL_ERROR_ACTION_3=''
EMAIL_ERROR_ACTION_4=''
EMAIL_ERROR_ACTION_5=''
EMAIL_ERROR_ACTION_6=''
EMAIL_ERROR_ACTION_7=''
EMAIL_ERROR_ACTION_8=''
EMAIL_ERROR_ACTION_9=''
EMAIL_ERROR_ACTION_10=''

########################################################################
#### MISCELLANEOUS SCRIPT OPTIONS ######################################
########################################################################
# miscellaneous script booleans
# Option: -m :do not mount backup drive, or umount it
B_SKIP_MOUNT='false' 
# Option: -s :use spinning wheel option
B_SPINNING_WHEEL='false' 
# Option: -! 1 :testing flag 1
B_TESTING_1='false' 
# Option: -! 2 :testing flag 2
B_TESTING_2='false' 
B_UPDATE_NOTIFIER='false' # if you want rbxi to notify you of newer versions, set true.

# try each one and see which works best for your terminal colors using -j <0-5>, then set it below.
# script color scheme: 0 - no colors; 1 - default simple, for dark on light or light on dark
# 2 - fancy dark on light; 3 - basic light on dark; 4 - fancy light on dark; 5 - smxi style
# Option: -j [0-5]
COLOR_SCHEME='1'

## uncomment then set only if you want to override the default console browser rbxi selects
## to show readme-rbxi.htm with -R option
# CONSOLE_BROWSER=''

## Logging Options ##
# if you do not want to use logging, set this to 'false'
# Option: -l - use logging is set to true.
B_LOGGING='true' 
## you can manually override the default logfile directory location here if you want (must end with /)
## Uncomment if you want to change rbxi default location to somewhere else in your system.
# LOGFILE_DIR='/var/log/'
## logfile max size, in kB. Must be an integer, for example: LOGFILE_SIZE=500
## Overrides script default size of 100kB. Uncomment to use override. Rbxi will
## automatically rotate the file one time, to rbxi.1.log in the logfile directory
## once it hits the size in kB given.
# LOGFILE_SIZE=100

# this is how fast the spinning wheel moves. Anything less than 0.5 not
# recommended due to performance problems on most machines.
# Lower number means wheel moves faster. Slower machine, change to 1
SLEEP_TIME_SPINNER='0.5'
# time between backup operations, make integer
SLEEP_TIME_BACKUP='3'
# time forced exit allows for disk write syncs before umount occurs
SLEEP_TIME_UMOUNT='5'

########################################################################
#### FINAL STEP - DO NOT SKIP! #########################################
########################################################################
# and last but not least, set this to 'true' once you are done. Failure to do this will make
# rbxi exit with errors, since you can't run it without having completed these user variables
B_VARIABLES_SET='false'

###**EOF**###
